package GUI;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;

import org.jdesktop.application.Application;

import javax.swing.SwingUtilities;


import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.util.*;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class first extends javax.swing.JFrame {
	private JPanel zero;
	private JPanel text;
	private static JLabel Age;
	private static JButton Submit;
	private static JTextField AgeField;
	private static JTextField SexField;
	private static JLabel Sex;
	private JPanel title;
	private JPanel jPanel3;
	private JPanel jPanel1;
	private JLabel jLabel1;

	private JPanel jPanel2;

	private JPanel heading;
	private String UserAge;
	private String UserSex;    //1 for man , 0 for woman
	
	
	
	
	

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				first inst = new first();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public first() {
		super();
		initGUI();
	}	
    
	class SubmitAction implements ActionListener{    
		public void actionPerformed(ActionEvent e){
			UserSex = SexField.getText();
			UserAge = AgeField.getText();
			MainPage frame = new MainPage();
			frame.valuePass(UserSex, UserAge);
			frame.setVisible(true);
			dispose();
			}}


	
	private void initGUI() {
		try {
			GridBagLayout thisLayout = new GridBagLayout();
			thisLayout.rowWeights = new double[] {0.0, 0.1};
			thisLayout.rowHeights = new int[] {54, 7};
			thisLayout.columnWeights = new double[] {0.0, 0.1};
			thisLayout.columnWidths = new int[] {113, 7};
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				zero = new JPanel();
				getContentPane().add(zero, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
			}
			{
				heading = new JPanel();
				getContentPane().add(heading, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				heading.setName("heading");
				{
					jLabel1 = new JLabel();
					heading.add(jLabel1);
					jLabel1.setName("jLabel1");
					jLabel1.setPreferredSize(new java.awt.Dimension(398, 47));
				}
			}
			{
				jPanel2 = new JPanel();
				GridBagLayout jPanel2Layout = new GridBagLayout();
				jPanel2Layout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0};
				jPanel2Layout.rowHeights = new int[] {40, 40, 40, 40};
				jPanel2Layout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
				jPanel2Layout.columnWidths = new int[] { 7};
				jPanel2.setLayout(jPanel2Layout);
				getContentPane().add(jPanel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jPanel2.setName("jPanel2");

			}
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jPanel1.setName("jPanel1");
				{
					JButton jButton4 = new JButton();
					zero.add(jButton4);
					jButton4.setName("jButton4");
					jButton4.setPreferredSize(new java.awt.Dimension(110, 50));
					try {
					    Image img = ImageIO.read(getClass().getResource("2.jpg"));
					    jButton4.setIcon(new ImageIcon(img));
					  } catch (IOException ex) {
						  
					  }
				}
			}
			{
				jPanel3 = new JPanel();
				GridBagLayout jPanel3Layout = new GridBagLayout();
				getContentPane().add(jPanel3, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jPanel3.setName("jPanel3");
				jPanel3Layout.rowWeights = new double[] {0.0, 0.1, 0.1, 0.1};
				jPanel3Layout.rowHeights = new int[] {32, 7};
				jPanel3Layout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
				jPanel3Layout.columnWidths = new int[] { 7};
				jPanel3.setLayout(jPanel3Layout);
				{
					title = new JPanel();
					jPanel3.add(title, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
					title.setName("title");
				}
				{
					text = new JPanel();
					GridBagLayout textLayout = new GridBagLayout();
					jPanel3.add(text, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
					text.setName("text");
					textLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
					textLayout.rowHeights = new int[] {7, 7, 7, 7};
					textLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
					textLayout.columnWidths = new int[] {7, 7, 7, 7};
					text.setLayout(textLayout);

					{
						Sex = new JLabel();
						text.add(Sex, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
						Sex.setName("Sex");
						Sex.setText("Sex: ");
					}
					{
						SexField = new JTextField();
						text.add(SexField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
						SexField.setName("jTextField1");
						this.UserSex = SexField.getText();
						
					}
					{
						Age = new JLabel();
						text.add(Age, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
						Age.setName("Age");
						Age.setText("Age: ");
					}
					{
						AgeField = new JTextField();
						text.add(AgeField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
						this.UserAge = AgeField.getText();
					}
					{
						Submit = new JButton();
						text.add(Submit, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
						Submit.setName("Submit");
						Submit.setText("Submit");
						Submit.addActionListener(new SubmitAction()); 
					}


				}

			}

			pack();
			this.setSize(650, 600);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	}


